<?php
/* 
 * ********* CVS HEADER ********* 
 * 
 * $RCSfile: admemailadd.php,v $ 
 * $Date: 2005/10/21 12:58:07 $ 
 * $Revision: 1.3 $ 
 * 
 * $Log: admemailadd.php,v $
 * Revision 1.3  2005/10/21 12:58:07  babeface
 * panneau de controle : version 1
 *
 * 
 * ********* CVS HEADER ********* 
 */
$op_f = $op;
if(!isset($eid)) $eid=-1;
if($eid<1) $eid=-1;
if($eid>0) $op_f='admemailliste';
if($action=="save"){
	$query='';
	if($eid>0){
		$query = "UPDATE rportal_email_type SET";
		$query.= " nom='$nom',";
		$query.= " titre='$titre',";
		$query.= " description='$description',";
		$query.= " message='$message'"; 	
		$query.= " WHERE id='".$eid."'";
	}else{
		$query = "INSERT INTO rportal_email_type";
		$query.= " (nom,description,titre,message) VALUES";
		$query.= " ('$nom','$description','$titre','$message')";
	}
	$result=rportalrequete($query) or rportalerreur($query,"?op=");
	header("Location: ?op=admemailliste");
	exit;
}

require_once("module/TPLN/TPLN.php"); 
$TPLN = new TPLN; 
$TPLN->Open($op_basepath."tpl/admemailedit.html"); 
$TPLN->IncludeFile("header","environnement/".$session['environnement']."/header.php"); 
$TPLN->IncludeFile("footer","environnement/".$session['environnement']."/footer.php");

require_once(get_path_module("admin"));
$pc = new panneau_controle();
$pc->calculRubriqueParFonction($op_f);
$TPLN->Parse("panneau_controle",$pc->retourneEntete());


$nom = '';
$description = '';
$titre = '';
$message = '';
$droit = 1;
$query = "SELECT * FROM rportal_email_type";
$query.= " WHERE rportal_email_type.id='".$eid."'";
$result=rportalrequete($query) or rportalerreur($query,"?op=");
if(rportalnbresult($result)!=1){
    $eid = -1;
}else{
    $email=rportalligne($result);
 	$nom = $email['nom'];
	$description = $email['description'];
	$titre = $email['titre'];
	$message = $email['message'];
	$droit = $email['droit'];  
}
$TPLN->Parse("nom",$nom);
$TPLN->Parse("description",$description);
$TPLN->Parse("titre",$titre);
$TPLN->Parse("message",$message);
$TPLN->Parse("eid",$eid);
$TPLN->Write();
?>